package com.ds.admin.config;

import jakarta.validation.MessageInterpolator;
import jakarta.validation.Validation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

/**
 * @class: ValidationConfig
 * @description:
 * @author: fs
 * @create: 2024/4/9 10:55
 **/
@Configuration
public class ValidationConfig {

	@Bean
	public LocalValidatorFactoryBean validatorFactoryBean() {
		LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean();
		MessageInterpolator interpolator = Validation.byDefaultProvider()
			.configure()
			.buildValidatorFactory()
			.getMessageInterpolator();
		factoryBean.setMessageInterpolator(new CustomMessageInterpolator(interpolator));
		return factoryBean;
	}

}
